package com.xiaoma.tpo.dao;

import java.util.List;

import org.springframework.stereotype.Repository;

import com.xiaoma.tpo.baseDao.BaseDaoImpl;
import com.xiaoma.tpo.domain.TRole;
import com.xiaoma.verbal.baseDao.DefaultRowMapper;

@Repository
public class TRoleDao extends BaseDaoImpl<TRole>{

	public List<TRole> findAllRoles() {
		String sql = "select *  from t_role ";
		return jdbcTemplate.query(sql, new DefaultRowMapper(TRole.class, this.getNameHandler()));
	}

	public void delete(Integer id) {
		String sql = "delete from t_role where id ="+id;
		jdbcTemplate.execute(sql);
	}

	public List<TRole> findByRoleName(TRole role) {
		// TODO Auto-generated method stub
		String sql = "select *  from t_role where role_name='"+role.getRoleName()+"'";
		return jdbcTemplate.query(sql, new DefaultRowMapper(TRole.class, this.getNameHandler()));
	}
	
}
